﻿using EntityModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace API.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class TeacherController : ControllerBase
    {
        private readonly DZJDBcontext db;

        public TeacherController(DZJDBcontext context)
        {
            db = context;
        }
        [HttpGet]
        public List<EM_Teacher> Get()
        {

            return db.EM_Teacher.ToList();
        }
        [HttpPost]
        public bool Add(EM_Teacher teacher)
        {
            db.EM_Teacher.Add(teacher);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
        [HttpPut]
        public bool Update(EM_Teacher teacher)
        {
            db.EM_Teacher.Update(teacher);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
        [HttpDelete]
        public bool Delete(EM_Teacher teacher)
        {
            db.EM_Teacher.Update(teacher);
            int result = db.SaveChanges();
            return result > 0 ? true : false;
        }
    }
}
